package com.farm.utils_all;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.TimeZone;

public class PayUtil {
	// 订单号
	public static String getCurrTime() {
		Date now = new Date();
		SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
		outFormat.setTimeZone(TimeZone.getTimeZone("GMT+08"));
		String s = outFormat.format(now);
		return s;
	}

	// 随机字符串
	public static String getRandomString(int length) {
		Random random = new Random();

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < length; ++i) {
			int number = random.nextInt(3);
			long result = 0;
			switch (number) {
			case 0:
				result = Math.round(Math.random() * 25 + 65);
				sb.append(String.valueOf((char) result));
				break;

			case 1:
				result = Math.round(Math.random() * 25 + 97);
				sb.append(String.valueOf((char) result));
				break;
			case 2:

				sb.append(String.valueOf(new Random().nextInt(10)));
				break;
			}
		}
		return sb.toString();
	}

	// 生成时间戳
	public static String getTempStamp() {
		Date date = new Date();
		long a = date.getTime() / 1000;
		String tempStamp = String.valueOf(a);
		return tempStamp;
	}
	
	//数字
	public static String random(int a1) {
		Random random = new Random();
		String result = "";
		for (int i = 0; i < a1; i++) {
			result += random.nextInt(10);
		}
		return result;
	}

	public static void main(String[] args) {
		new PayUtil();
		System.out.println("11 = "+PayUtil.getCurrTime());
//		Random random = new Random();
//		String result = "";
//		for (int i = 0; i < 20; i++) {
//			result += random.nextInt(10);
//		}
//		System.out.println(result);
	}
}
